<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>27_案例练习-打印10次老马然后清除定时器</title>
    </head>
    <body>
        <script>

            var n = 0;
            var timer = setInterval(function(){
                console.log('老马' + n);
                n++;

                if(n == 10){
                    clearInterval(timer);
                }
            },1000);
        </script>
    </body>
</html>